[#ftl]
[@define "agile.NavigatorPane" "ContentPane" "MenuBar=dijit/MenuBar,MenuBarItem=dijit/MenuBarItem,Toolbar=dijit/Toolbar,PopupMenuBarItem=dijit/PopupMenuBarItem,Menu=dijit/Menu,MenuItem=dijit/MenuItem"]
		name:"agileNavigator"	
		,constructor:function(){		
	//		agile.requireX("MenuBar");
	//		agile.requireX("MenuBarItem");
	//		agile.requireX("PopupMenuBarItem");
	//		agile.requireX("Toolbar");
		} 
		,postCreate:function(){			
			var menuBar = this.createMenuBar();		
			menuBar.placeAt(this.domNode,"last");
			style.set(menuBar.domNode,{border:"0px"});
	
			var toolbar = this.createToolbar();
			toolbar.placeAt(this.domNode,"last");
			style.set(toolbar.domNode,{border:"0px"});
			
			aspect.after(this,"startup",function(){
				menuBar.startup();
				toolbar.startup();
			});		
		}	
		,createMenuBar:function(){
			var menuBar = new MenuBar({});
[#--			
	//        var fileMenu = new Menu({});
	//        fileMenu.addChild(new MenuItem({
	//            label: agile.i18n("new_page",null,true)
	//            ,onClick:function(){
	//            	topic.publish("agile.workspace.command",["New"]);
	//            }
	//        }));
	//        fileMenu.addChild(new MenuItem({
	//            label: "Open Page"
	//            ,onClick:function(){
	//            	topic.publish("agile.workspace.command",["Open"]);
	//            }
	//        }));
	        
	//        fileMenu.addChild(new MenuItem({
	//            label: agile.i18n("save_workspace",null,true)
	//        	,onClick:function(){
	//            	topic.publish("agile.command",["Save"]);
	//            }	
	//        }));
	//        
	//		fileMenu.addChild(new MenuItem({
	//		   label: agile.i18n("open_workspace",null,true)
	//		   ,onClick:function(){
	//            	topic.publish("agile.workspace.command",["Open"]);
	//            }   
	//		}));
	//					
	//        menuBar.addChild(new PopupMenuBarItem({
	//            label: agile.i18n("File",null,true),
	//            popup: fileMenu
	//        }));
--] 
			 menuBar.addChild(new MenuBarItem({
		        	label: agile.i18n("Home",null,"Home")
		    		,onClick:function(){		    			
		    			[#if applicationMode = "DEV"]
		    				window.open("/v/index");
	    				[#else]
	    					window.open("/index.html");
		    			[/#if]		    			
		            }
		        	,title:agile.i18n("HomeHelp",null,"Open home page")
		        }));
			 
	        menuBar.addChild(new MenuBarItem({
	        	label: agile.i18n("Preview",null,"Preview")
	    		,onClick:function(){
	            	topic.publish("agile.workspace.command","Preview");    			
	            }
	        	,title:agile.i18n("PreviewHelp",null,"Preview current page")
	        }));
	        
	//        menuBar.addChild(new MenuBarItem({
	//        	label: agile.i18n("Export_Prototype",null,true)
	//    		,onClick:function(){
	//            	topic.publish("agile.workspace.command",["ExportPrototype"]);
	//            }
	//        }));
	        menuBar.addChild(new MenuBarItem({
	        	label: agile.i18n("Export_Source",null,true)
	    		,onClick:function(){
	            	topic.publish("agile.workspace.command","Export");
	            }
	        	,title:agile.i18n("ExportHelp",null,true)
	        }));
	     	     	        
	        //View configuration
	        var viewMenu = new Menu({style:"width:150px",title:"Please select views to show"});
	        array.forEach(["Widget_Repository","Metadata"],function(name){
	        	viewMenu.addChild(new MenuItem({
	        		name:name
		            ,label: agile.i18n(name,null,true)
		            ,accelKey:"&#8730;"
		            ,onClick:function(){	            	
		            	var key = this.get("accelKey");	            	
	            		this.set("accelKey",key?"":"&#8730;");
	            		topic.publish("agile.view",(key?"hide":"show"),name);	
		            }
	        		,startup:function(){
	        			this.subscribe("agile.view.status",function(name,checked){
	        				if(this.name == name){
	        					this.set("accelKey",checked?"&#8730;":"");
	        				}
	        			});
	        		}
		        }));	
	        });
	        
	        menuBar.addChild(new PopupMenuBarItem({
	        	label: agile.i18n("View",null,"View")
	        	,popup: viewMenu        	
	        }));
	        
	        var helpMenu = new Menu({style:"width:150px"});
	        helpMenu.addChild(new MenuItem({
	        	label:agile.i18n("About",null,"About Beyond Prototype")
	        	,onClick:function(){
	        		[#assign aboutMessage]<div style="font-size:1em">[@copyright/]<br/>[@support/]</div>[/#assign]
	        		topic.publish("agile.message.info","${aboutMessage?js_string}");
	        	}
	        }));
	        
	        menuBar.addChild(new PopupMenuBarItem({
	        	label: agile.i18n("Help",null,"Help")
	        	,popup: helpMenu        	
	        }));
	        [#--
	        menuBar.addChild(new MenuBarItem({
	        	label: agile.i18n("Demo",null,"Demo")
	        	,onClick:function(){
	            	topic.publish("agile.workspace.command","Demo");
	            }	        	
	        }));
	        --]
	        [#--
//	        menuBar.addChild(new MenuBarItem({
//	        	label: agile.i18n("Help",null,true)
//	    		,onClick:function(){
//	            	topic.publish("agile.workspace.command","Feature");
//	            }
//	        	,title:"Explore the features"
//	        }));
//	        
//	        menuBar.addChild(new MenuBarItem({
//	        	label: agile.i18n("Contact",null,true)
//	    		,onClick:function(){
//	            	topic.publish("agile.workspace.command","Support");
//	            }
//	        	,title:"Contact for support"
//	        }));
	        --]
	        [#--TODO:
	//        //var themeMenu = new Menu();
	//		var themeMenu = new form.Select({
	//			value:"Claro"
	//			,options:[{value:"claro",label:"Claro"},{value:"tundra",label:"Tundra"}]
	//			,onChange:function(value){
	//				domClass.replace(_window.body(),value);
	//			}
	//		});
	//                
	//        menuBar.addChild(new PopupMenuBarItem({
	//            label: "Theme",
	//            popup: themeMenu
	//        }));
	//       	    
	//	    var viewsMenu = new Menu();
	//	    viewsMenu.addChild(new MenuItem({
	//	    	label:"Metadata Workspace"
	//	    	,onClick:function(){
	//	    		topic.publish("agile.application.child-Show",["agileMetadataWorkspace"]);
	//	    	}
	//	    }));
	//	    viewsMenu.addChild(new MenuItem({
	//	    	label:"Widget Dashboard"
	//	    	,onClick:function(){
	//	    		//topic.publish("agile.application.child-Show",["agileMetadataWorkspace"]);
	//	    	}
	//	    }));
	//	    
	//	    var showViewsSubMenu = new PopupMenuItem({
	//	    	label:"Show Views"	   
	//	    	,popup: viewsMenu	
	//	    });
	//	    
	//	    var windowMenu = new Menu();
	//	    windowMenu.addChild(showViewsSubMenu);
	//	    
	//	    menuBar.addChild(new PopupMenuBarItem({
	//	        label: "Window",
	//	        popup: windowMenu
	//	    }));
	//    	    
	//		var languageMenu = new form.Select({
	//			value:"English"
	//			,options:[{value:"zh",label:"  "},{value:"en",label:"English"}]
	//			,onChange:function(value){
	//				//window.location.url = 
	//			}
	//		});
	//                
	//        menuBar.addChild(new PopupMenuBarItem({
	//            label: "  ",
	//            popup: languageMenu
	//        }));
	        --]
	        return menuBar;
		}
		,createToolbar:function(){
			var toolbar = new Toolbar();		
			var commands = ["Save","Copy","Cut",[#--"Paste",--]"Delete","Redo","Undo","Cancel","Sep","BackColor","ForeColor","HiliteColor","Bold","Italic","Indent","CreateLink","InsertHorizontalRule","InsertImage","InsertOrderedList","InsertTable","InsertUnorderedList","JustifyCenter","JustifyFull","JustifyLeft","JustifyRight","LeftToRight","ListBulletIndent","ListBulletOutdent","ListNumIndent","ListNumOutdent","Outdent","RemoveFormat","RightToLeft","Space","Strikethrough","Subscript","Superscript","Underline","Wikiword","ToggleDir"];
			
			array.forEach(commands,function(command,index){						
	            var button = new Button({                
	                label: nlsStrings["CmdTip"+command]?nlsStrings["CmdTip"+command]:""
	                ,showLabel: false
	                ,disabled: true//index > 3
	                ,iconClass: "dijitEditorIcon dijitEditorIcon" + command
	                ,onClick: function(event) {
	                    topic.publish("agile.command",command,event);
	                }
	            });
	            toolbar.addChild(button);
	            if(command == "Save"){
	            	button.set("disabled",false);
	            }else{
		            button.subscribe("agile.widget.selected",function(selectedTarget){
		            	this.set("disabled",selectedTarget==null||!selectedTarget.adviseContextState(command));
		            });
	            }
			});
			domClass.add(toolbar.domNode,"bp_hidden");
			
			return toolbar;
		}
[/@]
